<!DOCTYPE html>
<!-- 产品关联页面 -->
<html lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta charset="utf-8">
		<title>驴妈妈慧眼系统</title>
		<meta name="description" content="overview &amp; stats">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bootstrap.css">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/font-awesome/4.5.0/css/font-awesome.min.css">
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/daterangepicker.min.css">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/jquery.css">
		<!-- text fonts -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/fonts.css">
		<!-- ace styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-skins.min.css">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-rtl.min.css">
		<!-- ace settings handler -->
		<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script><style>@keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-moz-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-webkit-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-ms-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-o-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}.ace-save-state{animation-duration:10ms;-o-animation-duration:10ms;-ms-animation-duration:10ms;-moz-animation-duration:10ms;-webkit-animation-duration:10ms;animation-delay:0s;-o-animation-delay:0s;-ms-animation-delay:0s;-moz-animation-delay:0s;-webkit-animation-delay:0s;animation-name:nodeInserted;-o-animation-name:nodeInserted;-ms-animation-name:nodeInserted;-moz-animation-name:nodeInserted;-webkit-animation-name:nodeInserted}</style>
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bsie-paginator.css">
		<script src="${request.contextPath}/static/assets/js/jquery-2.1.4.min.js"></script>
		<style type="text/css">
			#linkRemind{
				width:300px
			}
			#deleteRemind{
				width:400px
			}
			/* 模态框居中样式 */
			 .modal-dialog {
			 	top:20%;
			 }
			 .page-content{padding: 0px 0px 0px!important;}
			 ::-webkit-scrollbar{ display: none;}
		</style>
	</head>

	<body class="skin-2" style="background-color: #FFF;">
		<div class="page-content">
			<div class="tabbable">
				<div class="tab-content">
				   <div id="manage" class="tab-pane active in">
					 <div class="row">
						<!-- 筛选条件 -->
						<div class="col-xs-12">
								<div class="widget-box">
									<div class="widget-body" style="background-color: #EFF3F8;">
										<div class="widget-main">
											<input type="hidden" id="companyCode" name="companyCode"/>
											<input type="hidden" id="productId" name="productId"/>
											<input type="hidden" id="sceneryName" name="sceneryName"/>
											<input type="hidden" id="province" name="province"/>
											<input type="hidden" id="starLevel" name="starLevel"/>
											<input type="hidden" id="cityCode" name="cityCode"/>
											<form class="form-inline" id="searchForm" action="${request.contextPath}/datashow/list" method="post">

											<input type="hidden" id="_csrf" name="${_csrf.parameterName}" value="${_csrf.token}"/>
											<#if productConditionVO??>
												<div class="form-group">
													<label  for="exampleInputName">产品ID
														<input class="form-control" name="productId" id="productIdVO" value="<#if productConditionVO.productId??>${productConditionVO.productId}</#if>" placeholder="模糊查询产品ID" type="text" style="width:123px">
													</label>
													<label  for="exampleInputName" style="margin-left: 30px;">产品名称
														<input class="form-control" name="sceneryName" id="sceneryNameVO"value="<#if productConditionVO.sceneryName??>${productConditionVO.sceneryName}</#if>" placeholder="模糊查询产品名称" type="text" style="width:123px">
													</label>
													<label  for="exampleInputName" style="margin-left: 30px;">所属城市
														<input class="form-control" name="cityCode" id="cityCodeVO"value="<#if productConditionVO.cityCode??>${productConditionVO.cityCode}</#if>" placeholder="模糊查询所属城市" type="text" style="width:123px" style="width:123px">
													</label>
													<label  for="exampleInputName" style="margin-left: 30px;">产品星级
														<input class="form-control" name="starLevel" id="starLevelVO"value="<#if productConditionVO.starLevel??>${productConditionVO.starLevel}</#if>" placeholder="模糊查询产品星级" type="text" style="width:123px">
													</label>
													<label  for="exampleInputName" style="margin-left: 30px;">业务编码
														<select name="businessCode" id="businessCodeSearch" aria-controls="dynamic-table" class="form-control input-sm" style="width:80px;height:34px">
														      <#if productConditionVO??&&productConditionVO.businessCode??&&productConditionVO.businessCode=="TICKET"><option value="TICKET" selected>门票</option><#else><option value="TICKET">门票</option></#if>
														      <#if productConditionVO??&&productConditionVO.businessCode??&&productConditionVO.businessCode=="HOTEL"><option value="HOTEL" selected>酒店</option><#else><option value="HOTEL">酒店</option></#if>
														</select>
													</label>
													<button type="submit" class="btn btn-pink btn-sm" id="search"  style="margin-left: 30px;">
														<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
														查询
													</button>
												</div>
											</#if>
											</form>	
										</div>
									</div>
								</div>
							</div>	
							<!-- table -->
							<div class="col-xs-12">
								<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
									<thead>
										<tr>
											<th>No.</th>
											<th>产品ID</th>
											<th>产品名称</th>
											<th>所属城市</th>
											<th>产品星级</th>
											<th>XC</th>
											<th>TN</th>
											<#if productConditionVO.businessCode??&&productConditionVO.businessCode=='TICKET'>
											<th>TC</th>
											<#elseif productConditionVO.businessCode??&&productConditionVO.businessCode=='HOTEL'>
											<th>EL</th>
											</#if>
											<th>QNR</th>
											<!-- 增加美团列-->
											<#if productConditionVO.businessCode??&&productConditionVO.businessCode=='TICKET'>
											<th>MT</th>
											</#if>
											<th>操作</th>
										</tr>
									</thead>
									<!-- 产品关联主界面数据展示 -->
									<tbody>
									<#if product??&&product?size&gt;0>
									<#list product as prod>

											<tr class="">
												<td>${prod_index + 1}</td>
												<td class="tdProductId"><#if prod.productId??>${prod.productId}</#if></td>
												<td class="tdSceneryName"><#if prod.sceneryName??>${prod.sceneryName}<#elseif prod.hotelName??>${prod.hotelName}</#if></td>
												<td class="cityCode"><#if prod.cityCode??>${prod.cityCode}</#if><span style="display:none" class="province" name="province" value=""><#if prod.province ?? >${prod.province}</#if></span></td>
												<td><#if prod.starLevel??>${prod.starLevel}<#else>暂无星级评定</#if><span style="display:none" class="starLevel" name="starLevel" value=""><#if prod.starLevel ?? >${prod.starLevel}</#if></td>
												<td id="xc_<#if prod.productId??>${prod.productId}</#if>" class="xc">
													<span class="selectedProductName"  id="<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodIdXC??&&rel.prodId==prod.productId>${rel.prodIdXC}</#if></#list></#if>">
													<#if relevances??&&relevances?size&gt;0>
													<#list relevances as rel>
													<#if rel.prodId??&&prod.productId??&&rel.prodNameXC??&&rel.prodId==prod.productId>${rel.prodNameXC}
													</#if>
													</#list>
													</#if>
													</span>
													<span class="hidden-sm hidden-xs action-buttons" style="float:right;cursor:pointer;">
														<a class="green" onclick="updateProduct(this);" role="button" name="xc" type="button">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red" onclick="deleteLink(this);" name="xc" role="button" style="display:none" type="button" data-toggle="modal" data-target="#deleteModal">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</span>	
											    </td>
												<td id="tn_<#if prod.productId??>${prod.productId}</#if>"class="tn">
													<span class="selectedProductName" id="<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodIdTN??&&rel.prodId==prod.productId>${rel.prodIdTN}</#if></#list></#if>">
													<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodNameTN??&&rel.prodId==prod.productId>${rel.prodNameTN}</#if></#list></#if>
													</span>
													<span class="hidden-sm hidden-xs action-buttons" style="float:right;cursor:pointer;">
														<a class="green" onclick="updateProduct(this);" role="button" name="tn">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red" onclick="deleteLink(this);" name="tn" style="display:none" type="button" data-toggle="modal" data-target="#deleteModal">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</span>														
											    </td>
											    <#if productConditionVO.businessCode??&&productConditionVO.businessCode=='TICKET'>
											    <td class="tc" id="tc_<#if prod.productId??>${prod.productId}</#if>">
													<span class="selectedProductName" id="<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodIdTC??&&rel.prodId==prod.productId>${rel.prodIdTC}</#if></#list></#if>">
													<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodNameTC??&&rel.prodId==prod.productId>${rel.prodNameTC}</#if></#list></#if>
													</span>
													<span class="hidden-sm hidden-xs action-buttons" style="float:right;cursor:pointer;">
														<a class="green" onclick="updateProduct(this);" role="button" name="tc">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red" onclick="deleteLink(this);" name="tc" style="display:none" type="button" data-toggle="modal" data-target="#deleteModal">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</span>														
											    </td>
											    <#elseif productConditionVO.businessCode??&&productConditionVO.businessCode=='HOTEL'>
											    <td class="el" id="el_<#if prod.productId??>${prod.productId}</#if>">
													<span class="selectedProductName" id="<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodIdEL??&&rel.prodId==prod.productId>${rel.prodIdEL}</#if></#list></#if>">
													<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodNameEL??&&rel.prodId==prod.productId>${rel.prodNameEL}</#if></#list></#if>
													</span>
													<span class="hidden-sm hidden-xs action-buttons" style="float:right;cursor:pointer;">
														<a class="green" onclick="updateProduct(this);" role="button" name="el">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red" onclick="deleteLink(this);" name="el" style="display:none" type="button" data-toggle="modal" data-target="#deleteModal">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</span>														
											    </td>
											    </#if>
												
												<td class="qnr" id="qnr_<#if prod.productId??>${prod.productId}</#if>">
													<span class="selectedProductName" id="<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodIdQNR??&&rel.prodId==prod.productId>${rel.prodIdQNR}</#if></#list></#if>">
													<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodNameQNR??&&rel.prodId==prod.productId>${rel.prodNameQNR}</#if></#list></#if>
													</span>
													<span class="hidden-sm hidden-xs action-buttons" style="float:right;cursor:pointer;">
														<a class="green" onclick="updateProduct(this);" role="button"  name="qnr">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red" onclick="deleteLink(this);" name="qnr" style="display:none" type="button" data-toggle="modal" data-target="#deleteModal">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</span>														
											    </td>
												<!-- 增加美团列-->
												<#if productConditionVO.businessCode??&&productConditionVO.businessCode=='TICKET'>
												<td class="mt" id="mt_<#if prod.productId??>${prod.productId}</#if>">
														<span class="selectedProductName" id="<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodIdMT??&&rel.prodId==prod.productId>${rel.prodIdMT}</#if></#list></#if>">
													<#if relevances??&&relevances?size&gt;0><#list relevances as rel><#if rel.prodId??&&prod.productId??&&rel.prodNameMT??&&rel.prodId==prod.productId>${rel.prodNameMT}</#if></#list></#if>
													</span>
													<span class="hidden-sm hidden-xs action-buttons" style="float:right;cursor:pointer;">
														<a class="green" onclick="updateProduct(this);" role="button"  name="mt">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red" onclick="deleteLink(this);" name="mt" style="display:none" type="button" data-toggle="modal" data-target="#deleteModal">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</span>
												</td>
												</#if>
												<td align='center'>
													<div class="hidden-sm hidden-xs action-buttons" style="cursor:pointer;" onclick="">
														<!--<a class="blue" onclick="skip('product_list?<#if prod.productId??>productId=${prod.productId}</#if>&<#if prod.sceneryName??>sceneryName=${prod.sceneryName}</#if>')" role='button'>  -->
														<a class="green" onclick="skipToCommodity(this);">
															<i class="ace-icon fa fa-search-plus bigger-130" title="商品列表"></i>
														</a>
														
														<#if prod.isLink??&&prod.isLink==1>
																<a class="white" role="button" title="未关联">
																	<i class="glyphicon glyphicon-adjust bigger-130"></i>
																</a>
														<#else >
																<#list relevances as rel>
																	<#if rel.prodId??&&prod.productId??&&rel.prodId==prod.productId>
																		<#if rel.isDeal??&&rel.isDeal==0>
																			<a class="red" onclick="relevanceStaus(this);" role="button" title="未处理">
																				<i class="glyphicon glyphicon-adjust bigger-130"></i>
																			</a>
																		<#else >
																			<a class="green" onclick="relevanceStaus(this);" role="button" title="已处理">
																				<i class="glyphicon glyphicon-adjust bigger-130"></i>
																			</a>
																		</#if>
																		<input type="hidden" class="relevanceStaus" value="${rel.id!}" />
																	</#if>
																</#list>
														</#if>
													</div>
											</td>
											</tr>
											
											</#list>
											</#if>
									</tbody>
								</table>
								<#include "paginator.html">
							</div>
						</div>
					<!-- 关联产品 -->
					<div class="row">
						<div class="col-xs-12">
							<button class="btn btn-info" data-toggle="modal" type="button"  style="display:none;" id="update" data-target="#myModal"></button>
							<form id="updateProduct" class="form-horizontal" role="form">
							<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								   <div class="modal-dialog">
								      <div class="modal-content">
								         <div class="modal-header">
								            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" id='close1'>
								                  ×
								            </button>
								            <h4 class="modal-title" id="myModalLabel">
								               	关联产品
								            </h4>
								         </div>
							         <div class="modal-body">
										<div class="form-group">
											<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <strong class="text-danger">*</strong>产品名称 </label>
											<div class="col-sm-8">
												<input id="selectSceneryName" name="selectSceneryName" class="col-xs-10 col-sm-8" type="text" placeholder="模糊查询产品名称">
												
												<div class="dataTables_length">
													<button class="btn btn-pink btn-sm" type="button" id="select">
														<span class="ace-icon fa fa-search icon-on-right bigger-90"></span>
														查询
													</button>
												</div>					
											</div>
											<div class="col-sm-12" id="detail"></div>
											
										</div>
							         </div>
							         <div class="modal-footer">
							            <button type="button" class="btn btn-default" data-dismiss="modal" id='close2'>关闭
							            </button>
							            <button id="save" type="button" class="btn btn-primary" data-dismiss="modal">
							              	 关联
							            </button>
							         </div>
							      </div><!-- /.modal-content -->
								</div><!-- /.modal -->
							</div>
							</form>
						</div>
					</div>
					<!-- 提醒关联产品 -->
					<button class="btn btn-info" data-toggle="modal" type="button" style="display:none;" id="linkForm" data-target="#linkModal">
							</button>
					<div class="modal fade" id="linkModal" tabindex="-1" role="dialog" aria-labelledby="linkModalLabel" aria-hidden="true">
					<div class="modal-dialog link" id="linkRemind">
						<div class="modal-content">
							<div class="modal-header" style="height:20px">
					            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" id='close1' style="height:10px;line-height:5px">
					                  <small>×</small>
					            </button>
				         	</div>
				         	<div class="modal-body">
				         			 
				         	</div>
				         	<div class="modal-footer" style="height:50px">
				         		<button type="button" class="btn btn-primary" data-dismiss="modal" style="height:30px;line-height:10px">
					              	 确定
					            </button>
				         	</div>
						</div>
					</div>
					</div>
					<!-- 删除提醒 -->
					<button class="btn btn-info" data-toggle="modal" type="button" style="display:none;" id="deleteForm" data-target="#deleteModal">
							</button>
					<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
					<input type="hidden" id="prodNameOther" name="prodNameOther"/>
					<input type="hidden" id="prodIdOther" name="prodIdOther"/>
					<input type="hidden" id="delCompanyCode" name="delCompanyCode"/>
					<input type="hidden" id="delProdId" name="delProdId"/>
					<div class="modal-dialog link" id="deleteRemind">
						<div class="modal-content">
							<div class="modal-header" style="height:40px">
					            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" id='close1' style="height:10px;line-height:5px">
					                  <small>×</small>
					            </button>
					            <strong style="height:10px;line-height:5px;font-size:15px" id="deleteTitle">是否确认删除关联？</strong>
				         	</div>
				         	<div class="modal-body">
				         			 <span style="color:red;padding-left:50px">确认会同时删除该产品所有的商品关联！</span>
				         	</div>
				         	<div class="modal-footer" style="height:50px">
				         		<button type="button" class="btn btn-default" data-dismiss="modal" style="height:30px;line-height:10px">
							    	取消
							    </button>
				         		<button type="button" class="btn btn-primary" data-dismiss="modal" style="height:30px;line-height:10px" id="confirmDelete">
					              	 确定
					            </button>
				         	</div>
						</div>
						</div>
						</div>
					</div><!-- row -->
				</div><!-- col-sm-12 -->
			</div><!-- row -->
		</div><!-- page-content -->
		
		
		
		<input type="hidden" id="listcontext" value="${request.contextPath}"/>
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) 
				document.write("<script src='${request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
				
		<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
		<script src="${request.contextPath}/static/assets/js/spin.js"></script>
		<!-- ace scripts -->
		<script src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
		<!-- validator scripts -->
		<script src="${request.contextPath}/static/assets/js/bootstrapValidator.min.js"></script>
		<!-- user scripts -->
		<script src="${request.contextPath}/static/assets/js/user/base.js"></script>
		
		<script type="text/javascript">
		$("#myModal").draggable();
		$("#deleteModal").draggable();
		var listcontext = $("#listcontext").val();
		var updateProduct = function(obj){
			    $("#selectSceneryName").val("");//每次点击时都清空该项目中的内容
                companyCode=$(obj).parents("td").attr("class");
				sceneryName=$(obj).parents("tr").find(".tdSceneryName").text().trim();
				prodId=$(obj).parents("tr").find(".tdProductId").text().trim();
            	province=$(obj).parents("tr").find(".province").text().trim();
        	    starLevel=$(obj).parents("tr").find(".starLevel").text().trim();
            	cityCode=$(obj).parents("tr").find(".cityCode").text().trim();
            	$("#cityCode").val(cityCode);
				$("#update").click();
			    $("#productId").val(prodId);
                $("#province").val(province);
                $("#starLevel").val(starLevel);
                $("#companyCode").val(companyCode);
			    $("#sceneryName").val(sceneryName);
			    $("#select").click();//此处设置点击弹框后，默认查询该公司对应的所有产品，其中id为selectSceneryName的隐藏域的值会影响查询结果
                $("#selectSceneryName").val(sceneryName);//此处在弹框结束后再设置值


			};
			//点击弹框中的查询业务逻辑
			$("#select").click(function(){
				$("#detail div").remove();
				companyCode=$("#companyCode").val().trim();
				sceneryName=$("#sceneryName").val().trim();
				businessCode=$("#businessCodeSearch").val();
				selectSceneryName=$("#selectSceneryName").val().trim();
                province=$("#province").val().trim();
                starLevel=$("#starLevel").val().trim();
                productId=$("#productId").val().trim();
                cityCode=$("#cityCode").val().trim();
				$.ajax({
					url : listcontext+'/datashow/select',
					type : "GET",
					data : {
						companyCode:companyCode,
						sceneryName:sceneryName,
						selectSceneryName:selectSceneryName,
						businessCode:businessCode,
                        province:province,//省份
                        starLevel:starLevel,//星级
                        lvProductId:productId,//城市
                        cityCode:cityCode
					},
					success:function(data){
						if(data.sessionStatus==540){//异步请求session过期状态
							window.location.href=listcontext+"/login";
							return;
						}else{
							productData=data.product;
							hotelData=data.hotels;
							var table="<div style='height:250px;width:550px;overflow:auto'><table class='table table-striped table-bordered table-hover dataTable no-footer'>";
							thead="<thead><th></th><th>产品id</th><th>产品名称</th></thead>";
							table+=thead;
							if(productData!=null&&productData.length>0){
								tbody="";
								$.each(productData,function(n,value) {   
							       var trs = ""; 
							       names=value.sceneryName.split("_")
							       prodNameRel=names[0]
							       prodNameLmm=""
							       if (names.length>1){
							    	   prodNameLmm=names[1]
							       }
							       trs += " <tr><td class='comProductId'> " +value.productId+" </td> <td class='comSceneryName'>" + prodNameRel +"</td >";  
							       if(value.is_link==1){
							    	   trs+="<td style='color:red'>"+prodNameLmm+"</td></tr>";
							       }else{
							    	   trs+="<td><input name='comSceneryName' type='radio' /></td></tr>";
							       }
							       
							       tbody += trs;
							     });  
								table+=tbody;
								table+="</table></div>";
								$("#detail div").remove();
							     $("#detail").append(table);  
							}else if(hotelData!=null&&hotelData.length>0){
								tbody="";
								$.each(hotelData,function(n,value) {   
							       var trs = "";  
							       names=value.hotelName.split("_")
							       prodNameRel=names[0]
							       prodNameLmm=""
							    	   if (names.length>1){
								    	   prodNameLmm=names[1]
								       }
							       trs += " <tr><td class='comProductId'> " +value.productId+" </td> <td class='comSceneryName'>" + prodNameRel +"</td >";  
							       
							       if(value.isLink==1){
							    	   trs+="<td style='color:red'>"+prodNameLmm+"</td></tr>";
							       }else{
							    	   trs+="<td><input name='comSceneryName' type='radio' /></td></tr>";
							       }
							       
							       tbody += trs;
							     });  
								table+=tbody;
								table+="</table></div>";
								$("#detail div").remove();
							     $("#detail").append(table); 
							}else{
								msg=data.msg;
								$("#detail div").remove();
								$("#detail").append("<div style='color:red;font-size:15px;padding-left:180px'><br/>"+msg+"</div>")
							}
							//每次结束后
						}
						
					}
				});
			});
			
			$("#save").click(function(){
				prodId=$("#productId").val().trim();
				companyCode=$("#companyCode").val().trim();
				businessCode=$("#businessCodeSearch").val();
				var table=$("#detail div table");
				 if($('input:radio').is(':checked')&& table!="none"){
					 prodIdOther=$('input:radio:checked').parents("tr").find(".comProductId").text().trim();
					 prodNameOther=$('input:radio:checked').parents("tr").find(".comSceneryName").text().trim();
					$.ajax({
						url : listcontext+'/datashow/link',
						type : "GET",
						data : {
							companyCode:companyCode,
							prodId:prodId,
							prodIdOther:prodIdOther,
							prodNameOther:prodNameOther,
							businessCode:businessCode
						},
						success:function(data){
							if(data.sessionStatus==540){//异步请求session过期状态
								window.location.href=listcontext+"/login";
								return;
							}else{
								comId=companyCode+"_"+prodId;
								$("#"+comId).find(".selectedProductName").text("");
								$("#"+comId).find(".selectedProductName").text(prodNameOther);
								$("#detail div").remove();
								$("#"+comId).find("a.green").hide();
								$("#"+comId).find("a.red").show();
							}
							
						}
					});
				}else{
					//bootbox.alert("<strong style='padding-left:50px;font-size:15px'>没有可关联的产品！</strong>");
					$("#detail div").remove();
					$("#linkForm").click();
					$("#linkRemind").find(".modal-body").text("").append("<strong style='padding-left:70px'>请选择要关联的产品！</strong>")
				}
			});
			$("#close1").click(function(){
				$("#detail div").remove();
			});
			$("#close2").click(function(){
				$("#detail div").remove();
			});
			
			$("#confirmDelete").click(function(){
				prodNameOther=$("#prodNameOther").val();
				prodIdOther=$("#prodIdOther").val();
				companyCode=$("#delCompanyCode").val();
				prodId=$("#delProdId").val();
				businessCode=$("#businessCodeSearch").val();
				$.ajax({
					url : listcontext+'/datashow/deleteLink',
					type : "GET",
					data : {
						companyCode:companyCode,
						prodId:prodId,
						prodIdOther:prodIdOther,
						prodNameOther:prodNameOther,
						businessCode:businessCode
					},
					success:function(data){
						if(data.sessionStatus==540){//异步请求session过期状态
							window.location.href=listcontext+"/login";
							return;
						}else{
							comId=companyCode+"_"+prodId;
							$("#"+comId).find(".selectedProductName").text("");
							$("#"+comId).find("a.green").show();
							$("#"+comId).find("a.red").hide();
						}
						
					}
				});
				
			})
			
			var deleteLink=function(obj){
				selectedProductName=$(obj).parent().prevAll(".selectedProductName");
				prodNameOther=selectedProductName.text().trim();
				prodIdOther=selectedProductName.attr("id").trim();
				companyCode=selectedProductName.parent().attr("class").trim();
				prodId=selectedProductName.parent().attr("id").split("_")[1].trim();
				$("#selectedProductName").val(selectedProductName);
				$("#prodNameOther").val(prodNameOther);
				$("#prodIdOther").val(prodIdOther);
				$("#delCompanyCode").val(companyCode);
				$("#delProdId").val(prodId);
				$("#deleteTitle").text("");
				$("#deleteTitle").append("是否删除"+companyCode+""+prodNameOther+"的关联？");
				/*
				$(function() {
					bootbox.confirm("<strong style='font-size:15px;padding-left:200px'>是否确认删除关联？</strong>", function(result){
						if(result){
							//ajax返回信息到后台删除关联信息
							selectedProductName=$(obj).parent().prevAll(".selectedProductName");
							prodNameOther=selectedProductName.text().trim();
							prodIdOther=selectedProductName.attr("id").trim();
							companyCode=selectedProductName.parent().attr("class").trim();
							prodId=selectedProductName.parent().attr("id").split("_")[1].trim();
							$.ajax({
								url : '/datashow/deleteLink',
								type : "GET",
								data : {
									companyCode:companyCode,
									prodId:prodId,
									prodIdOther:prodIdOther,
									prodNameOther:prodNameOther
								},
								success:function(data){
									$(obj).parent().prevAll(".selectedProductName").text("");
									$(obj).hide();
									$(obj).prev().show();
								}
							});
						}
					});
					});*/
	
			};
			
			$(".selectedProductName").each(function(index,data){ 
				if ($(data).text().trim()!=""&&$(data).text()!=null){
					$(data).parent().find("a.green").hide();
					$(data).parent().find("a.red").show();
				}else{
					$(data).parent().find("a.red").hide();
					$(data).parent().find("a.green").show();
				}
			});

			//跳转商品关联界面
			skipToCommodity=function(obj){
				selects=$(obj).parents("tr").find(".selectedProductName");//获取隐藏域中的值
				productIdVO=$("#productIdVO").val();
				sceneryNameVO=$("#sceneryNameVO").val();
				cityCode=$("#cityCodeVO").val();
				starLevel=$("#starLevelVO").val();
				businessCode=$("#businessCodeSearch").val();
				var i=0;
				selects.each(function(index,data){
					if ($(data).text().trim()!=""&&$(data).text()!=null){
						i+=1;
					}
				});
				if(i==0){
					$("#linkForm").click();
					$("#linkRemind").find(".modal-body").text("").append("<strong style='padding-left:70px'>请先关联产品！</strong>");
				}else{
					tdProductId=$(obj).parents("tr").find(".tdProductId").text();
					tdSceneryName=$(obj).parents("tr").find(".tdSceneryName").text();
					location.href=listcontext+"/datashow/product_list?productId="+tdProductId+"&sceneryName="+tdSceneryName+"&prodPageNum="+$("#prodPageNum").val()+
					"&cityCode="+cityCode+"&starLevel="+starLevel+"&productIdVO="+productIdVO+"&sceneryNameVO="+sceneryNameVO+"&businessCode="+businessCode;
				}
			}
			
			
			function relevanceStaus(obj,status){
				 var productRelevanceId = $(obj).parent().find(".relevanceStaus").val().trim();
				 var className = $(obj).attr('class');
				 var status = 0;
				 if(className=="red"){
					 status=1;
				 }
	     	  	 $.ajax({  
			          url: "${request.contextPath}/datashow/change/relevance/status?status="+status+"&relevanceId="+productRelevanceId,  
			          type: 'GET',  
			          timeout: 12000,
			          async: false,  
			          cache: false,  
			          contentType: false,  
			          processData: false,
			          success: function (data) { 
			              if(data.Success!=null){
			            	  if(className=="red"){
			            		  $(obj).removeAttr("class");
			            		  $(obj).attr("class","green");
			            		  $(obj).attr("title","已处理");
			            	  }else if(className=="green"){
			            		  $(obj).removeAttr("class");
			            		  $(obj).attr("class","red");
			            		  $(obj).attr("title","未处理");
			            	  }
			              }
			          }
			     });  
			     	  	
			}
				
		</script>
	</body>
</html>